package com.zhang.Builder.example;

import java.util.ArrayList;

/**
 * @author ElloeStudy(Sifa Zhang)
 * @create 2022-03-06 20:23
 * To: 真常应物，真常得性，常清常静，常清静矣
 */

// 导演类，安排生产模型
public class Director {
    private ArrayList<String> sequence = new ArrayList<>();
    private BenzBuilder benzBuilder = new BenzBuilder();
    private BMWBuilder bmwBuilder = new BMWBuilder();

    // A车的模型
    public BenzModel getABenzModel(){
        // 清理场景 ， 把之前的顺序清理掉
        this.sequence.clear();
        // 这个BenzModel的执行顺序
        this.sequence.add("start");
        this.sequence.add("stop");
        // 返回一个这个要求下的奔驰车模型
        this.benzBuilder.setSequence(this.sequence);
        return (BenzModel) this.benzBuilder.getCarModel();
    }

    // B车的模型
    public BenzModel getBBenzModel(){
        this.sequence.clear();

        this.sequence.add("engineboom");
        this.sequence.add("start");
        this.sequence.add("stop");

        this.benzBuilder.setSequence(this.sequence);
        return (BenzModel) this.benzBuilder.getCarModel();
    }

    //C类车的模型
    public BMWModel getCBMWModel(){
        this.sequence.clear();

        this.sequence.add("alarm");
        this.sequence.add("start");
        this.sequence.add("stop");

        this.bmwBuilder.setSequence(this.sequence);
        return (BMWModel) this.bmwBuilder.getCarModel();
    }

    // D车模型
    public BMWModel getDBMWModel(){
        this.sequence.clear();

        this.sequence.add("start");

        this.bmwBuilder.setSequence(this.sequence);
        return (BMWModel) this.bmwBuilder.getCarModel();
    }
}
